Skip to content

[composite] Remove unnecessary props memos#5023

Open
atomiks wants to merge 2 commits into
mui:masterfrom
atomiks:composite/remove-props-memos
Open

[composite] Remove unnecessary props memos#5023
atomiks wants to merge 2 commits into
mui:masterfrom
atomiks:composite/remove-props-memos

Conversation

@atomiks

@atomiks atomiks commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

The props object returned by useCompositeRoot is consumed only by CompositeRoot, which passes it into useRenderElementmergeProps — re-merged unconditionally every render, so the object's identity is never compared. The memo's ~15-entry dep array included highlightedIndex, so it invalidated on every arrow-key navigation anyway, and was pure maintenance burden with stale-closure risk.

  • useCompositeRoot: the props object is now created per render. onKeyDown is wrapped in useStableCallback because its identity (as relayKeyboardEvent) does matter: it flows into the CompositeRootContext value memo and into useTriggerDataForwarding's effect deps via Object.values(stateUpdates). It's now fully stable, where previously it changed on every navigation.
  • useCompositeRoot: the return-value memo is also removed — CompositeRoot is the only consumer and destructures it immediately.
  • useCompositeItem: compositeProps memo removed — both consumers (CompositeItem, TabsTab) only pass it into useRenderElement props arrays.
  • useCompositeListItem: return-value memo removed — all consumers only access .ref (already useCallback'd, identity unchanged) and .index; the wrapper object identity is never used.

Tests: Composite (jsdom + Chromium), Tabs and Menubar (jsdom) all pass; pnpm typescript and eslint clean.

@atomiks atomiks added type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. component: composite labels Jun 12, 2026
@atomiks atomiks requested a review from flaviendelangle as a code owner June 12, 2026 01:50
@atomiks atomiks added type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. component: composite labels Jun 12, 2026
@atomiks atomiks force-pushed the composite/remove-props-memos branch from 033b02a to d22c5aa Compare June 12, 2026 01:51
@atomiks atomiks changed the title [composite] Remove non-load-bearing props memos [composite] Remove unnecessary props memos Jun 12, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jun 12, 2026

Copy link
Copy Markdown

commit: 9616401

@netlify

netlify Bot commented Jun 12, 2026

Copy link
Copy Markdown

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 033b02a
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a2b66055561a600081b9e65
😎 Deploy Preview https://deploy-preview-5023--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@code-infra-dashboard

code-infra-dashboard Bot commented Jun 12, 2026

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react ▼-137B(-0.03%) ▼-53B(-0.04%)

Details of bundle changes

Performance

Total duration: 1,126.88 ms -117.21 ms(-9.4%) | Renders: 50 (+0) | Paint: 1,712.47 ms -166.05 ms(-8.8%)

Test Duration Renders
Checkbox mount (500 instances) 62.81 ms ▼-37.02 ms(-37.1%) 1 (+0)

11 tests within noise — details


Check out the code infra dashboard for more information about this PR.

@netlify

netlify Bot commented Jun 12, 2026

Copy link
Copy Markdown

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 9616401
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a2b7d255d6d9800089761f7
😎 Deploy Preview https://deploy-preview-5023--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Jun 12, 2026
# Conflicts:
#	packages/react/src/internals/composite/root/useCompositeRoot.ts
@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: composite type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant